import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:liuxlcommon/view/extension_widget.dart';
import 'package:liuxlcommon/view/lxl_widget.dart';
import 'package:liuxlcommon/view/my_box.dart';
import 'package:liuxlcommon/view/my_style.dart';
import 'package:ladder_cash/config/super_theme.dart';
import 'package:ladder_cash/generated/assets.dart';
import 'package:ladder_cash/value/app_colors.dart';

class LoginInputWeiget extends StatefulWidget {
  LInputType type;
  String text;
  String? hintText;
  String? leftText;
  String? leftAssets;
  int? flex;
  double? width;
  double? height;
  double? radius;
  int? maxLength;
  ValueChanged<String> onChange;
  FocusNode phoneNode = FocusNode();
  LoginInputWeiget(this.text,
      {this.leftText,
      this.leftAssets,
      this.width,
      this.flex,
      this.radius,
      this.height,
      this.hintText,
      this.type = LInputType.TEXT,
      this.maxLength,
      required this.onChange,
      Key? key})
      : super(key: key);

  @override
  _LoginInputPageState createState() => _LoginInputPageState(text);
}

class _LoginInputPageState extends State<LoginInputWeiget> {
  bool isPwdHide = false;

  _LoginInputPageState(this.text);

  String text = "";

  @override
  void initState() {
    super.initState();
    if (widget.type == LInputType.PASSWORD) isPwdHide = true;
  }

  @override
  Widget build(BuildContext context) {
    return LRow(lStyle: boxStyle, children: [
      if(widget.leftAssets != null) LImage.easy(widget.leftAssets, 15.w, 20.w),
      3.lsw,
      LText(widget.leftText, lStyle: leftStyle),
      7.lsw,
      LContainer(
          lStyle: LStyle(
              width: 1,
              height: 14.w,
              backgroundColor: const Color(0x40999999)
          )),
      7.lsw,
      Expanded(
          child: LInput(
            text,
            focusNode: widget.phoneNode,
            lInputType: widget.type,
            lStyle: LStyle(
                alignment: Alignment.center,
                fontWeight: FontWeight.w500,
                // height:60.w,
                fontSize: 14.sp,
                hintText: widget.hintText,
                hintColor: SuperTheme.grey9F,
                obscureText: isPwdHide,
                maxLength: widget.maxLength),
            onChanged: (text) {
              this.text = text;
              widget.onChange(text);
            },
          )),
    ]);
  }

  @override
  void dispose() {
    super.dispose();
  }

  get boxStyle => LStyle(
        css: '''
        padding:0 12px;
width: 315px;
height: 45px;
border-radius: 5px 5px 5px 5px;
      ''',
      );

  get leftStyle => LStyle(
        // padding: EdgeInsets.only(top: 2.w),
        css: ''' font-weight: 400;
font-size: 15px;
color: #333333;''',
      );
}
